import { _decorator, Component, Node } from 'cc';
import { UIBase } from './UIBase';
import { Singleton } from '../comm/Singleton';
const { ccclass, property } = _decorator;

@ccclass('UIManager')
export class UIManager extends Singleton<UIManager> {
    @property([UIBase])
    public uiList: UIBase[] = [];

    public openUI(ui: UIBase){
        ui.onEnter();
        console.log('Open UI : ',ui.uiName);
    }

    public closeUI(ui: UIBase){
        ui.onExit();
        console.log('Close UI : ',ui.uiName);
    }

    public getUI(uiName: string){
        for(let e of this.uiList){
            if(e.uiName == uiName){
                return e;
            }
        }

        console.log('Not found ui: ' + uiName)
        return null;
    }
}


